package live.betterman.system.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import live.betterman.system.model.SysMenu;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface SysMenuMapper extends BaseMapper<SysMenu> {
    @Select("SELECT DISTINCT m.* FROM sys_menu m " +
            "LEFT JOIN sys_role_menu rm ON m.menu_id = rm.menu_id " +
            "LEFT JOIN sys_user_role ur ON rm.role_id = ur.role_id " +
            "WHERE ur.user_id = #{userId} AND m.status = 'on' " +
            "ORDER BY m.sort")
    List<SysMenu> selectMenusByUserId(@Param("userId") String userId);
}
